package cz.cuni.mff.ufal.volk.boot;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class FileBootCodeLoader implements BootCodeLoader {
  
  private final File file;
  
  public FileBootCodeLoader(File file) {
    this.file = file;
  }

  @Override
  public BootCode loadBootCode(String version, String serial) {
    return new FileBootCode(file);
  }
  
  private static class FileBootCode implements BootCode {
    
    final File file;
    
    FileBootCode(File file) {
      this.file = file;
    }

    @Override
    public InputStream getInputStream() throws FileNotFoundException {
      return new FileInputStream(file);
    }

    @Override
    public long size() {
      return file.length();
    }
    
  }

}
